package pl.oczadly.jabberclient.mainwindow.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import pl.oczadly.jabberclient.mainwindow.presenter.GeneralPresenter;
import pl.oczadly.jabberclient.mainwindow.presenter.IGeneralPresenter;
import pl.oczadly.jabberclient.utils.Utils;

public class GeneralView {

	private IMainView mainView;
	
	public GeneralView( IMainView mainView ) {
		this.mainView = mainView;
	}
	
	public void addGeneralView( JMenuBar menuBar ) {
		JMenu jcMenu = new JMenu( Utils.JABCLIENT );
		
		JMenuItem restartItem = new JMenuItem( Utils.RESTART );
		
		JMenuItem exitItem = new JMenuItem( Utils.EXIT );
		exitItem.addActionListener( new ExitListener() );
		
		jcMenu.add( restartItem );
		jcMenu.add( exitItem );
		
		menuBar.add( jcMenu );
	}
	
	
	private class ExitListener implements ActionListener {
		public void actionPerformed( ActionEvent e ) {
			IGeneralPresenter presenter = new GeneralPresenter( mainView );
			presenter.exit();
		}
	}
	
}
